import unittest
from page.login_page import LoginPage, get_driver
import time

class LoginTestCase(unittest.TestCase):
    @classmethod
    def setUpClass(cls) -> None:
        driver = get_driver()
        cls.login_page = LoginPage(driver)

    def test_01_login(self):
        # 访问login页面
        self.login_page.get(LoginPage.login_url)

        # 登录正确的账号密码
        self.login_page.username_input('root')
        self.login_page.password_input('123456')
        self.login_page.submit_button()
        time.sleep(2)
        # 获取actual_username
        self.actual_username = self.login_page.username_text()

        # 断言
        self.assertEqual('root',self.actual_username)

    @classmethod
    def tearDownClass(cls) -> None:
        cls.login_page.page_quit()


if __name__ == '__main__':
    unittest.main(verbosity=2)